<template>
	<view>
		<uni-card title="宠物分类">
			<view class="item-container">
				<view class="thumb-box" v-for="(item1, index1) in fen" @click="dianji(item1.id)" :key="index1">
					<image class="item-menu-image" :src="base+item1.imgUrl" mode=""></image>
					<view class="item-menu-name">{{item1.name}}</view>
				</view>
			</view>
		</uni-card>
		<uni-group title="我的问诊">
			<view v-for="(item,index) in wen" @click="wenxian(index)">
				<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-border-bottom">
					<view class="u-m-r-10">
						<u-avatar :src="base+item.doctor.avatar" size="100"></u-avatar>
					</view>
					<view class="u-flex-1">
						<view class="u-font-18 u-p-b-20">{{item.doctor.name}}</view>
						<view class="u-font-14 u-tips-color">案例描述:{{item.question}}</view>

					</view>
				</view>
			</view>
		</uni-group>
		<uni-group title="公开案例">
			<view v-for="(item,index) in wen1"  @click="wenxian2(index)">
				<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-border-bottom">
					<view class="u-m-r-10">
						<u-avatar :src="item.doctor == null?'':base+item.doctor.avatar" size="100"></u-avatar>
					</view>
					<view class="u-flex-1">
						<view class="u-font-18 u-p-b-20">{{item.doctor == null?'':item.doctor.name}}</view>
						<view class="u-font-14 u-tips-color">案例描述:{{item.question}}</view>

					</view>
				</view>
			</view>
		</uni-group>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				fen: [],
				wen: [],
				wen1: []
			}
		},
		onBackPress() {
			uni.switchTab({
				url:'../allserver',
			})
			return true
		},
		onLoad() {
			this.getlun()
			this.getlun2()
			this.getlun3()
		},
		methods: {
			wenxian2(index) {
				uni.setStorage({
					key: 'wen',
					data: this.wen1[index],
					success: (res) => {
						uni.navigateTo({
							url:'anli'
						})
					}
				})
			},
			wenxian(index) {
				uni.setStorage({
					key: 'wen',
					data: this.wen[index],
					success: (res) => {
						uni.navigateTo({
							url:'wenzhenxianq'
						})
					}
				})
			},
			dianji(id) {
				uni.navigateTo({
					url: 'zhaoyis?id=' + id
				})
			},
			getlun() {
				this.$get(this.base + '/prod-api/api/pet-hospital/pet-type/list').then((res) => {
					this.fen = res.data
				})
			},
			getlun2() {
				this.$get(this.base + '/prod-api/api/pet-hospital/inquiry/my-list').then((res) => {
					this.wen = res.rows
				})
			},
			getlun3() {
				this.$get(this.base + '/prod-api/api/pet-hospital/inquiry/list').then((res) => {
					this.wen1 = res.rows
					console.log(this.wen1)
				})
			},

		}
	}
</script>

<style>
	.item-container {
		display: flex;
		flex-wrap: wrap;
	}

	.thumb-box {
		width: 20%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		margin-top: 20rpx;
	}

	.item-menu-image {
		width: 60rpx;
		height: 60rpx;
	}
</style>
